<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <meta name="format-detection" content="telephone=no"/>
    <title>向商户付款</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../css/aui-flex.css"/>
    <style type="text/css">
        .unActive, .unActive input {
            background: #f5f5f5;
            font-size: 14px !important;
        }

        .aui-input {
            font-size: 18px !important;
        }

        .aui-input-addon {
            color: #666 !important;
        }

        .confirmRow:after {
            border: none;
        }

        .line {
            position: relative;
            /*animation:1s blink infinite;*/

        }

        .line:before {
            position: absolute;
            content: "";
            width: 1px;
            background: #000;
            height: 40%;
            top: 50%;
            -webkit-transform: translateY(-50%);
            -moz-transform: translateY(-50%);
            -ms-transform: translateY(-50%);
            -o-transform: translateY(-50%);
            transform: translateY(-50%);
            right: 12px;
            -webkit-animation: 1.5s blink infinite steps(1);
            -o-animation: 1.5s blink infinite steps(1);
            animation: 1.5s blink infinite steps(1);
            z-index: 99;
        }

        @keyframes blink {
            50% {
                background: transparent;
            }
        }
        @-webkit-keyframes blink {
            50% {
                background: transparent;
            }
        }

        .sure {
            background: #59ba37 !important;
        }
    </style>
</head>
<body>


<div class="aui-content">

    <div class="aui-flex-col">
        <div class="aui-flex-item-12 aui-flex-row aui-padded-20">
            <h3><i class="aui-iconfont aui-icon-shop"
                   style="background:#59ba37;color:#fff;border-radius:3px;padding:2px;"></i>&nbsp;&nbsp;<em
                    class="supplierName">---</em></h3>
            <span class="aui-text-default" style="font-size:12px;margin-top:2px;margin-left:30px;">爱奖励合作商家</span>

        </div>
    </div>

    <div class="aui-card">
        <div class="aui-form">
            <div class="aui-input-row line">
                <span class="aui-input-addon">&nbsp;&nbsp;支付金额 ¥</span>
                <input type="text" class="aui-input aui-text-right" autocomplete="off" placeholder="请输入金额"
                       oninput="checkInput(this)" onpropertychange="checkInput(this)" id="money" readonly value=""/>
            </div>
        </div>
    </div>
    <!--<div class="aui-card aui-hide">-->
    <!--<div class="aui-form">-->
    <!--<div class="aui-input-row unActive">-->
    <!--<span class="aui-input-addon">&nbsp;&nbsp;手机号</span>-->
    <!--<input type="tel" class="aui-input aui-text-right" placeholder="请输入手机号码" oninput="checkInput(this)"-->
    <!--onpropertychange="checkInput(this)" autocomplete="off" id="mobile" readonly value=""/>-->
    <!--</div>-->
    <!--</div>-->
    <!--</div>-->
    <!-- <div class="aui-btn-row confirmRow" style="padding-top:0">
        <div class="aui-btn aui-btn-block aui-btn-warning" onclick="checkForm();">确认支付</div>
    </div> -->
</div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/keyboard2.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/myInfo.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/echo.js"></script>
<script type="text/javascript" src="../script/jquery-1.11.3.js"></script>

<script type="text/javascript">
    var supplierId = "";
    apiready = function () {
        getUserInfo();
        api.parseTapmode();
        supplierId = api.pageParam.supplierId;
        getSupplierInfo()

        var money = document.getElementById('money');

        new KeyBoard(money);
    }
    //    (function () {
    //        var money = document.getElementById('money');
    //
    //        new KeyBoard(money);
    //    })();

    function getSupplierInfo() {
        showLoading()
        var url = "supplier/info";
        var data = {};
        data["supplier_id"] = supplierId;
        getStorageAll();
        ajaxRequest(url, 'get', data, function (ret, err) {

            $(".supplierName").text(ret.data.supplier_name)
            hideLoading();
//        var content = $api.byId('supplierInfo-content');
//        var tpl = $api.byId('supplierInfo-template').text;
//        var tempFn = doT.template(tpl);
//        $api.html(content, '');
//        $api.html(content, tempFn(ret.data));
        });
    }
    $(function () {
        $('.aui-input-row').unbind('click').bind('click', function () {
            $('.aui-input-row').addClass('unActive');
            $(this).removeClass('unActive');

            $('.line').removeClass('line');
            $(this).addClass('line');

            new KeyBoard($(this).find('input').get(0));

            $("#money").val(returnFloat($("#money").val()));
            checkInput();
        });
    })


    function returnFloat(value) {
        if (value) {
            var value = Math.round(parseFloat(value) * 100) / 100;
            var xsd = value.toString().split(".");
            if (xsd.length == 1) {
                value = value.toString() + ".00";
                return value;
            }
            if (xsd.length > 1) {
                if (xsd[1].length < 2) {
                    value = value.toString() + "0";
                }
                return value;
            }
        }
    }
    function checkInput(obj) {

        var moneyVal = $("#money").val();
//        var mobileVal = $("#mobile").val();

//        var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
//        if (myreg.test(mobileVal)&&moneyVal) {
        if (moneyVal) {
            $(".btnSure").addClass("sure");
        } else {
            $(".btnSure").removeClass("sure");
        }
    }

    function showMoneyRow() {
        var $money = $("#money");
        $money.closest('.aui-input-row').trigger('click');
        $money.val(returnFloat($money.val()));

        var money = document.getElementById('money');
        new KeyBoard(money);
    }

    function showMobileRow() {
        var $mobile = $("#mobile");
        $mobile.val('').closest('.aui-input-row').trigger('click');

        var mobile = document.getElementById('mobile');
        new KeyBoard(mobile);
    }

    function finishInput() {
        var money = $("#money").val();
//        var mobile = $("#mobile").val();
        if (!money) {
            alert('请输入支付金额');

            var $money = $("#money");
            $money.closest('.aui-input-row').trigger('click');
            var money = document.getElementById('money');
            new KeyBoard(money);

            return false;
        } else {
            money = returnFloat(money);
            $("#money").val(money);
        }
        QRGoToPay(money)
    }


    function QRGoToPay(moneys) {
        showLoading()
        var url = "order/payparam";
        var data = {};
        data["amount"] = moneys;
        data["supplier_id"] = supplierId;
        data["mobile"] = user_name;
        ajaxRequest(url, 'get', data, function (ret, err) {

            var appid = ret.data.appid;
            var noncestr = ret.data.noncestr;
            var package = ret.data.package;
            var partnerid = ret.data.partnerid;
            var prepayid = ret.data.prepayid;
            var sign = ret.data.sign;
            var timestamp = ret.data.timestamp;
            wxpay(appid, noncestr, package, partnerid, prepayid, sign, timestamp)
        });
    }
</script>


</html>